home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / GroupBoxEditor.cpp < prev    next >
Text File  |  1997-08-10  |  4KB  |  139 lines

  1. /*
  2.  *  File:       GroupBoxEditor.cpp
  3.  *  Summary:       A view that knows how to edit a TGroupBox.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    12/01/96    JDJ        Created
  12.  */
  13.  
  14. #include "GroupBoxEditor.h"
  15.  
  16. #include <ZColorSwatch.h>
  17. #include <ZTextBox.h>
  18.  
  19. #include "RsrcPopupMenu.h"
  20.  
  21.  
  22. // ===================================================================================
  23. //    class CEditGroupBoxCommand
  24. // ===================================================================================
  25.  
  26. //---------------------------------------------------------------
  27. //
  28. // CEditGroupBoxCommand::~CEditGroupBoxCommand
  29. //
  30. //---------------------------------------------------------------
  31. CEditGroupBoxCommand::~CEditGroupBoxCommand()
  32. {
  33. }
  34.  
  35.  
  36. //---------------------------------------------------------------
  37. //
  38. // CEditGroupBoxCommand::CEditGroupBoxCommand
  39. //
  40. //---------------------------------------------------------------
  41. CEditGroupBoxCommand::CEditGroupBoxCommand(TGroupBox* pane, const SGroupBoxInfo& oldInfo, const SGroupBoxInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  42. {
  43. }
  44.  
  45.  
  46. //---------------------------------------------------------------
  47. //
  48. // CEditGroupBoxCommand::UpdatePane
  49. //
  50. //---------------------------------------------------------------
  51. void CEditGroupBoxCommand::UpdatePane(const SGroupBoxInfo& info)
  52. {
  53.     mPane->SetText(info.text);
  54.     mPane->SetTextTraits(info.traitsID);
  55.     mPane->SetSecondary(info.secondary);
  56. }
  57.  
  58. #pragma mark -
  59.  
  60. // ===================================================================================
  61. //    CGroupBoxEditor
  62. // ===================================================================================
  63.  
  64. static TReanimatorRegister<CGroupBoxEditor> sGroupBoxEditorRegistrar;
  65.  
  66. //---------------------------------------------------------------
  67. //
  68. // CGroupBoxEditor::~CGroupBoxEditor
  69. //
  70. //---------------------------------------------------------------
  71. CGroupBoxEditor::~CGroupBoxEditor()
  72. {
  73. }
  74.  
  75.  
  76. //---------------------------------------------------------------
  77. //
  78. // CGroupBoxEditor::CGroupBoxEditor
  79. //
  80. //---------------------------------------------------------------
  81. CGroupBoxEditor::CGroupBoxEditor(TView* superView) : Inherited(superView)
  82. {
  83. }
  84.  
  85.  
  86. //---------------------------------------------------------------
  87. //
  88. // CGroupBoxEditor::Create                                [static]
  89. //
  90. //---------------------------------------------------------------
  91. MReanimatable* CGroupBoxEditor::Create(MReanimatable* parent)
  92. {
  93.     return new CGroupBoxEditor(dynamic_cast<TView*>(parent));
  94. }
  95.  
  96.  
  97. //---------------------------------------------------------------
  98. //
  99. // CGroupBoxEditor::GetEditorInfo            
  100. //
  101. //---------------------------------------------------------------
  102. SGroupBoxInfo CGroupBoxEditor::GetEditorInfo() const
  103. {
  104.     SGroupBoxInfo info;
  105.     
  106.     TTextBox* textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Text"));
  107.     info.text = textBox->GetText();
  108.     
  109.     CRsrcPopupMenu* popup = dynamic_cast<CRsrcPopupMenu*>(this->FindSubPane("Traits ID"));
  110.     info.traitsID = popup->GetID();
  111.     
  112.     TControl* control = dynamic_cast<TControl*>(this->FindSubPane("Secondary"));
  113.     info.secondary = control->GetValue();
  114.     
  115.     return info;
  116. }
  117.  
  118.  
  119. //---------------------------------------------------------------
  120. //
  121. // CGroupBoxEditor::SetEditorInfo
  122. //
  123. //---------------------------------------------------------------
  124. void CGroupBoxEditor::SetEditorInfo(const SGroupBoxInfo& info)
  125. {
  126.     TTextBox* textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Text"));
  127.     textBox->SetText(info.text);
  128.     
  129.     CRsrcPopupMenu* popup = dynamic_cast<CRsrcPopupMenu*>(this->FindSubPane("Traits ID"));
  130.     popup->SetID(info.traitsID);
  131.  
  132.     TControl* control = dynamic_cast<TControl*>(this->FindSubPane("Secondary"));
  133.     control->SetValue(info.secondary);
  134.     
  135. }
  136.  
  137.  
  138.  
  139.